<?php
/**
 * 需求任务工时进度表qa_timepro
 * String id
 * String qa_item【任务id】
 * String daily【日报id】
 * String time【工时】
 * String progress【进度】
 * String add_time【发布需求的时间】
 */
class App_Model_QaTimepro extends App_Model_Abstract
{
	public function init()
	{
		parent::init();
		$this->table = App_Db_Table::factory('QaTimepro');
	}

	public function add($row)
	{
		return $this->table->insert($row);
	}

	public function delete($id)
	{
		$db = $this->table->getAdapter();
		$where = $db->quoteInto('id = ?', $id);
	
		return $this->table->delete($where);
	}

	public function getOne($id)
	{
		$row = $this->table->find($id);
		if ($row) {
			return $row->current();
		}
		return array();
	}
	
	public function update($row, $id)
	{
		$db = $this->table->getAdapter();
		$where=array();
		$where[] = $db->quoteInto('id = ?', $id);
		$where=join(' AND ',$where);
	
		return $this->table->update($row, $where);
	}
	
	public function getQaTimepro($fieldArray)
	{
		$select = $this->table->select();
		if($fieldArray!=null){
			foreach ($fieldArray as $field => $value){
				$select->where("$field = ?",$value);
			}
		}
		$select->order('add_time asc');
		return $this->table->fetchAll($select);
	}
	
}